package simulation;

public class WaterBottles1518 {
    public int numWaterBottles(int numBottles, int numExchange) {
        int resBottles = 0;
        int result = 0;
        while (numBottles > 0) {
            result += numBottles;
            int temp = (numBottles+resBottles) / numExchange;
            resBottles = (numBottles+resBottles) % numExchange;
            numBottles = temp;
        }
        return result;
    }
}
